define(function(require, exports, module) {
	
	require("form");
	require("index/profile.css");
	
	module.exports = function() {
		return {
			data: {
				title:$.i18n.prop("info.profile"),
				tab:{
					password:$.i18n.prop("profile.password.manager"),
					launcher:$.i18n.prop("profile.launcher.manager")
				},
				content:{
					password:{
						type: 'password',
						newPassword:{
							label:$.i18n.prop("profile.password.manager.new"),
							placeholder:$.i18n.prop("sys.placeholder", [$.i18n.prop("profile.password.manager.new")])
						},
						oldPassword:{
							label:$.i18n.prop("profile.password.manager.old"),
							placeholder:$.i18n.prop("sys.placeholder", [$.i18n.prop("profile.password.manager.old")])
						},
						button: {
							submit: $.i18n.prop("sys.submit")
						}
					},
					launcher: {
						launchers:[],
						tipText:$.i18n.prop("profile.launcher.manager.nolaunchers"),
						on:$.i18n.prop("info.on"),
						off:$.i18n.prop("info.off")
					}
				}
			},
			methods: {
				init: function(data) {
					this.initLauncher();
					return true;
				},
				initLauncher:function() {
					var me = this;
					$.post("/api/index/launchers", {}, function(data) {
						if(data.success) {
							me.content.launcher.launchers = data.message;
						}
					}, "json");
				},
				onSwitchChange:function(launcher) {
					$.post("/api/index/launcher", {
						lid:launcher.id,
						enable:launcher.enable
					}, function() {}, "json");
				},
				passwordSubmit:function() {
					var me = this;
					var form = $(this.$el).find(".ivu-tabs-content:eq(0)").find("form");
					if(form.validate()) {
						this.loading();
						form.ajaxSubmit(function(data) {
							me.loading("close");
							if(data.success) {
								form.setFormValue({
									oldPassword:"",
									password:""
								});
								$.success($.i18n.prop("sys.success"));
							} else if(data.message == 1) {
								$.error($.i18n.prop("profile.password.manager.old.error"));
							}
						});
					}
				},
				changePassworeType:function() {
					this.content.password.type = this.content.password.type == 'password' ? 'text' : 'password';
				},
				destroy: function() {
					
				}
			}
		}
	}
});